import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 设定路由的名字，一定要填写不然使用<keep-alive>时会出现各种问题

const routes = [
    {
        path: '/index',//首页
        name: 'Index',
        component: (resolve) => require(['@/views/home'], resolve),
        meta: {
            anon: false,
        }
    },
    {
        path: '/login',//登录页
        name: 'Login',
        component: (resolve) => require(['@/views/login'], resolve),
        meta: {
            anon: true,
        }
    },
    {
        path: '/account',//个人中心
        name: 'Account',
        component: (resolve) => require(['@/views/account'], resolve),
        children: [
            {
                path: 'profile',//我的学习历程
                name: 'AccountProfile',
                component: (resolve) => require(['@/views/account/profile'], resolve),
            },

            {
                path: 'setting',//我的薪酬
                name: 'AccountSetting',
                component: (resolve) => require(['@/views/account/setting'], resolve),
            },

            {
                path: '/',
                redirect: 'profile'
            }
        ],

    },
    {
        path: '/',
        redirect: 'index'
    }
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})

export default router
